package com.demo.swingquickticket.swing.layoutUtil;

import lombok.extern.slf4j.Slf4j;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
@Slf4j
public class AppLabelCellRenderer extends DefaultTableCellRenderer {
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        this.setHorizontalAlignment(SwingConstants.CENTER);
        if (column >= 7) {
            if ("无".equals(value) || "*".equals(value)) {
                this.setBackground(Color.RED);
            } else {
                this.setBackground(Color.GREEN);
            }
        } else {
            this.setBackground(Color.WHITE);
        }
        return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    }
}
